const Base = (name: string) => {
  const fn: ClassDecorator = (target) => {
    // target 是类的构造函数
    target.prototype.xiaomin = name
    target.prototype.fn = () => {
      console.log('woshohanhan');
    }
  }
  return fn
}

const Get = (url: string) => {
  const fn: MethodDecorator = (target, propertyKey, descriptor: TypedPropertyDescriptor<any>) => {
    let propKey = Reflect.getMetadata('propKey', target)
    fetch(url).then(res => {
      descriptor.value(propKey ? res.data[propKey] : res.data) // res.data[propKey] 相当于 res.data.result
    })
  }
  return fn
}

const Result: ParameterDecorator = (target, propertyKey, parameterIndex) => {
  Reflect.defineMetadata('propKey', 'result', target)
}

const Name: PropertyDecorator = (target, propertyKey) => {

}

@Base('xiaohua')
class Http {
  // ... 原有的一大堆的代码

  @Name
  name: string

  constructor() {
    this.name = 'xiaomin'
  }

  @Get('https://img1.baidu.com/it/u=94904965,608097738&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500')
  getList(@Result data: any) {
    console.log(data);
  }
}
